# 操作mysql，安装 pymysql
import pymysql
from pymysql import cursors

# 连接数据库
connect = pymysql.connect(host='shop-xo.hctestedu.com',
                          port=3306,
                          user='api_test',
                          password='Aa9999!',
                          db='shopxo_hctested',
                          charset='utf8',
                          cursorclass=cursors.DictCursor)
# 创建游标对象
cursor = connect.cursor()

sql = "SELECT id,username FROM sxo_user WHERE username LIKE 'jeremy%';"
cursor.execute(sql)
# 查看全部
result = cursor.fetchall()

# 只看第一条数据
# result1 = cursor.fetchone()

print(result)

# 关闭游标和数据库连接
cursor.close()
connect.close()